<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title><?php echo $this->systemName;?></title>
<link rel="stylesheet" href="<?php echo $this->baseUrl;?>/files/admin/css/main.css" />
<script language="javascript" src="<?php echo $this->baseUrl;?>/files/admin/js/jquery.js"></script>
<link rel="stylesheet" href="<?php echo $this->baseUrl;?>/files/admin/js/formValidator.jquery/style.css" />
<script language="javascript" src="<?php echo $this->baseUrl;?>/files/admin/js/formValidator.jquery/cn.js"></script>

</head>

<body>
	<div id="main">
		<div id="navigation">当前位置：<a href="<?php echo $this->projectUrl(array('action'=>'index'));?>">主协议列表</a> &gt; <a href="<?php echo $this->projectUrl(array('action'=>'main-id-define','mainVersion'=>$this->vars['mainVersion'],'fieldType'=>$this->vars['fieldType']));?>"><?php echo $this->vars['mainVersion'];?> <?php echo isset($this->fieldTypeRows[$this->vars['fieldType']]['nameNote']) ? $this->fieldTypeRows[$this->vars['fieldType']]['nameNote'] : '';?> (<?php echo $this->vars['fieldType'];?>) id定义列表</a> &gt;<span id="focus">添加id</span></div>
		<div id="body">
			<div id="edit">
				<form id="editForm" name="editForm" method="post" action="">
					<table class="table">
						<tr>
							<td colspan="2">*为必填项</td>
						</tr>
						<tr>
							<td width="20%">主协议版本号：</td>
							<td>
								<?php echo $this->vars['mainVersion'];?>
								<input name="mainVersion" type="hidden" id="mainVersion" value="<?php echo $this->vars['mainVersion'];?>" />
							</td>
						</tr>
						<tr>
							<td width="20%">字段类型：</td>
							<td>
								<select name="fieldType" id="fieldType">
								<?php foreach($this->fieldTypeRows as $row) {
										if ($row['code']=='A'||$row['code']=='C'){
								?>
								<option value="<?php echo $row['code'];?>" <?php echo $this->vars['fieldType'] == $row['code'] ? ' selected="selected"' : '';?>><?php echo $row['nameNote'];?></option>
								<?php	 }
									}
								?>
								</select>
							</td>
						</tr>
						<tr>
							<td width="20%">
							<?php if ($this->vars['fieldType']=='C'){
									echo '页面Id：';
								}else if($this->vars['fieldType']=='A'){
									echo '操作Id：';
								}
							?></td>
							<td>
								<input name="pageId" type="text" class="validate[callback[checkPageId,1]] input" id="pageId" value="" size="30" style="width:300px;" /> * 
							</td>
						</tr>
						<tr>
							<td width="20%">
							<?php if ($this->vars['fieldType']=='C'){
									echo '页面名称：';
								}else if($this->vars['fieldType']=='A'){
									echo '操作名称：';
								}
							?></td>
							<td>
								<input name="pageName" type="text" class="validate[required] input" id="pageName" value="" size="30" style="width:300px;" /> * 
							</td>
						</tr>
						<tr>
							<td width="20%">辅助参数：</td>
							<td><textarea name="aidNote" cols="30" rows="5" class="input" id="aidNote" style="width:300px;"></textarea></td>
						</tr>
						<tr>
							<td width="20%">BI特殊关联ID：</td>
							<td>
								<input name="relationId" type="text" class="input" id="relationId" value="" size="30" style="width:300px;" />
							</td>
						</tr>
						<tr>
							<td width="20%">当前是否使用：</td>
							<td>
								<input name="isUse" type="checkbox" value="1" checked="checked"/>
							</td>
						</tr>
						<tr>
							<td width="20%">BI平台判定是否埋点：</td>
							<td>
								<input name="isUseBi" type="checkbox" value="1" checked="checked"/>
							</td>
						</tr>
						<tr>
							<td width="20%">重要标记：</td>
							<td>
								<input name="isFlag" type="checkbox" value="1" checked="checked"/>
							</td>
						</tr>
						<tr>
							<td width="20%">备注：</td>
							<td><textarea name="note" cols="30" rows="5" class="input" id="note" style="width:300px;"></textarea></td>
						</tr>
						<tr>
							<td width="20%">&nbsp;</td>
							<td><input type="submit" name="button" id="button" value="提交" class="button"/></td>
						</tr>
					</table>
				</form>
			</div>
		</div>
	</div>

<script language="javascript">
function checkPageId(account)
{
    var url = '<?php echo $this->projectUrl(array('action'=>'get-main-pact-page-id-is-exists-by-json','mainVersion'=>$this->vars['mainVersion'],'fieldType'=>$this->vars['fieldType'], 'account'=>'{account}'), NULL, false);?>'+'?rand/' + Math.random();
	url = url.replace('{account}', account);
	checkResult = {'isRight':true, 'message':''};
	
	if ($.trim($("#pageId").val()) == '') {
		return checkResult = {'isRight':false, 'message':' [页面|操作]Id。'};
	}
	if (account != '') {
		$.ajax({
			type: "GET",
			url: url,
			dataType: "json",
			async: false,
			success: function(data){
				if (data == 1) {
					checkResult = {'isRight':false, 'message':'* 此协议版本号下的此[页面|操作]Id已存在，请换一个。'};
				}
			} 
		}); 
	}
	return checkResult;
}

$("#editForm").submit(function(){
	return true;
});
</script>
</body>
</html>